package com.telenav.app;

import java.util.LinkedList;
import java.util.List;

import android.app.Activity;
import android.app.Application;

public class YYApplication extends Application {

	private List<Activity> activities = new LinkedList<Activity>();

	private static YYApplication instance;

	public void onCreate() 
	{
		super.onCreate();
		instance = this;
	}
	
	public static YYApplication getInstance()
	{   
        return instance;
	}

	public void addActivity(Activity activity) 
	{
		activities.add(activity);
	}

	public void removeActivity(Activity activity) 
	{
		for (Activity activityTemp : activities) 
		{
			if(activityTemp == activity)
			{
				activities.remove(activityTemp);
			}
		}
	}

	public void exit() 
	{
		for (Activity activity : activities) 
		{
			activity.finish();
		}
		System.exit(0);
	}

	public void onLowMemory() 
	{
		super.onLowMemory();
		System.gc();
	}
}
